/**
 * @file LoggerManager.cpp
 * @author  haifeng (haifengxiao@icloud.com)
 * @brief
 * @version 0.1
 * @date 2021-07-06
 *
 * @copyright Copyright (c) 2021
 *
 */

#include "LoggerManager.h"
#include "StdoutLogAppender.h"

namespace Chen {
    namespace Log {

        LoggerManager::LoggerManager() {
            m_root.reset(new Logger);
            m_root->addAppender(LogAppender::ptr(new StdoutLogAppender));
            //TODO: 重要修改
            m_loggers[m_root->m_name] = m_root;
            init();
        }

        Logger::ptr LoggerManager::getLogger(const std::string& name) {
            auto it = m_loggers.find(name);
            if (it != m_loggers.end()) {
                return it->second;
            }
            Logger::ptr logger(new Logger(name));
            logger->m_root = m_root;
            m_loggers[name] = logger;
            return logger;
        }

        void LoggerManager::init() {

        }

    }//nemespace Log
}//namespace Chen
